onload = function(){

	var mytabs = document.querySelector('.section_center .myCarousel'),
		li     = document.querySelectorAll('#mytabs li'),
		p      = document.querySelectorAll('.tabs_dot p'),
		priv   = document.getElementById('priv'),
		next   = document.getElementById('next'),
		header_b = document.querySelector('.myheader .header_bottom'),
		ControlLi = document.querySelectorAll('.mytabControl .tabControl_title ul li'),
		lineP = document.querySelectorAll('.mytabControl .tabControl_title #dot_line')[0],
		tabControl_middle = document.querySelectorAll('.mytabControl .tabControl_middle'),
		listR = document.querySelectorAll('.mytabControl .tabControl_middle .tabControl_middle_list_r ul li'), 
		listR_a = document.querySelectorAll('.mytabControl .tabControl_middle .tabControl_middle_list_r ul li a'),
		num    = 0;

	li[0].className = 'active';
	p[0].className = 'active';

	if(mytabs != null){

		for(var i=0;i<ControlLi.length;i++){
		
			ControlLi[i].index = i;
			ControlLi[i].onclick = function(){

				tireAddOne(ControlLi, tabControl_middle, this.index);
				tireAddOne(listR_a, listR, this.index);

				lineP.style.left = this.index * 120 + "px";

			}
		}

		for(var i=0; i<listR_a.length;i++){

			listR_a[i].index = i;
			var tIndex = this.index;
			listR_a[i].onmouseover = function(){

				tireAddOne(listR_a, listR, this.index);
			}
		}


		// 鼠标移入事件
		mytabs.onmouseover = function(){

			clearInterval(timer);
			priv.style.display = "inline-block";
			next.style.display = "inline-block";
		}
		// 鼠标移出事件
		mytabs.onmouseout = function(){

			timer = setInterval(add, 2000);
			priv.style.display = "none";
			next.style.display = "none";
		}
		// 被选元素被点击后
		priv.onclick = minus; 
		next.onclick = add;

		// for(var i = 0; i < li.length; i++){

		// 	li[i].onmousedown = function(){

		// 		this.onmouseout = function(){

		// 			add();
		// 		}
		// 	}
		// }

		// 指针在被选元素上时
		for(var i=0; i<p.length; i++){

			p[i].index = i;
			p[i].onmouseover = function(){
			
				num = this.index;

				tireAddOne(li, p, num);
			}

		}

		var timer = setInterval(add, 2000);

		function add(){
			
			num++;

			if(num == li.length){

				num = 0;
			}
			tireAdd(li, p, num);
		}

		function minus(){
			
			num--;

			if(num < 0){

				num = li.length - 1;
			}
			tireAdd(li, p, num);
		}
	}
}